﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;

namespace DFGK_WMS.Model.Models
{
    /// <summary>
    /// 出库单明细
    /// </summary>
    public partial class TShippingOrderDetail
    {
        /// <summary>
        /// 主键
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// 出库订单号(拣配单号)
        /// </summary>
        public string OrderSn { get; set; }

        /// <summary>
        /// 单据类型
        /// </summary>
        public int? BillType { get; set; }

        /// <summary>
        /// 优先级:默认为0
        /// </summary>
        public int? Proirity { get; set; }

        /// <summary>
        /// 状态：0-新建;1-提交；2-审核通过;3-作业中;4-已完成;5-强制完成;6-失效;7-异常
        /// </summary>
        public int Status { get; set; }
        
        /// <summary>
        /// 库房编码
        /// </summary>
        public string WarehouseCode { get; set; }

        /// <summary>
        /// 库房名称
        /// </summary>
        public string WarehouseName { get; set; }

        /// <summary>
        /// 库区编码
        /// </summary>
        public string AreaCode { get; set; }

        /// <summary>
        /// 库区名称
        /// </summary>
        public string AreaName { get; set; }

        /// <summary>
        /// 物料ID
        /// </summary>
        public int MaterialId { get; set; }

        /// <summary>
        /// 物料号，对应公共数据库中的物料主数据表,指定仓位出库的时候物料号允许为空
        /// </summary>
        public string MaterialCode { get; set; }

        /// <summary>
        /// 物料名称
        /// </summary>
        public string MaterialName { get; set; }

        /// <summary>
        /// 物料类型码
        /// </summary>
        public string MaterialTypeCode { get; set; }

        /// <summary>
        /// 批次号
        /// </summary>
        public string BatchNo { get; set; }
        /// <summary>
        /// 小批次号
        /// </summary>
        public string SmallBatchNo { get; set; }

        /// <summary>
        /// 质量状态
        /// </summary>
        public int? QualityState { get; set; }

        /// <summary>
        /// 计量单位编号
        /// </summary>
        public int? UnitId { get; set; }

        /// <summary>
        /// 计量单位名称
        /// </summary>
        public string UnitName { get; set; }

        /// <summary>
        /// 预期出货数量
        /// </summary>
        [Column(TypeName = "decimal(18,2)")]
        public decimal? Qty { get; set; }

        /// <summary>
        /// 出库站台Id
        /// </summary>
        public int? StationId { get; set; }

        /// <summary>
        /// 预期出库站台或站台组
        /// </summary>
        public string StationName { get; set; }

        /// <summary>
        /// erp编码
        /// </summary>
        public string Erpcode { get; set; }

        /// <summary>
        /// 包装数量(总出库数量) 现在是装车数量用于蒙牛所有的出库单的装车数量都是一样所以用的时候直接取集合的第一个就行
        /// </summary>
        public int? PackQty { get; set; }

        /// <summary>
        /// 已经下架的数量（西安库存调增平库库存数量）
        /// </summary>
        [Column(TypeName = "decimal(18,2)")]
        public decimal? PickedQty { get; set; } = 0;

        /// <summary>
        /// 已经出库完成的数量
        /// </summary>
        [Column(TypeName = "decimal(18,2)")]
        public decimal? ShippedQty { get; set; } = 0;

        /// <summary>
        /// 订单完成日期
        /// </summary>
        public DateTime? FinshDate { get; set; }

        /// <summary>
        /// 单据来源类型：0-手动建单；1-ERP;2-MES;3-SAP
        /// </summary>
        public int? SourceType { get; set; }

        /// <summary>
        /// 创建用户Id
        /// </summary>
        public int? CreateUserId { get; set; }

        /// <summary>
        /// 创建用户名
        /// </summary>
        public string CreateUserName { get; set; }

        /// <summary>
        /// 创建日期
        /// </summary>
        public DateTime? CreateDate { get; set; }

        /// <summary>
        /// 修改用户ID
        /// </summary>
        public int? ModifyUserId { get; set; }

        /// <summary>
        /// 修改用户
        /// </summary>
        public string ModifyUserName { get; set; }

        /// <summary>
        /// 修改日期
        /// </summary>
        public DateTime? ModifyDate { get; set; }

        /// <summary>
        /// 提交人Id
        /// </summary>
        public int? SubmitUserId { get; set; }

        /// <summary>
        /// 提交人（西安目标仓储区）
        /// </summary>
        public string SubmitUserName { get; set; }

        /// <summary>
        /// 提交时间
        /// </summary>
        public DateTime? SubmitDate { get; set; }

        /// <summary>
        /// 审核人Id
        /// </summary>
        public int? AuditUserId { get; set; }

        /// <summary>
        /// 审核人
        /// </summary>
        public string AuditUserName { get; set; }

        /// <summary>
        /// 审核时间
        /// </summary>
        public DateTime? AuditDate { get; set; }

        /// <summary>
        /// 物料凭证号（领料单号）
        /// </summary>
        public string Mblnr { get; set; }

        /// <summary>
        /// 物料凭证年度（领料单行号）
        /// </summary>
        public string Mjahr { get; set; }

        /// <summary>
        /// 物料凭证行项目
        /// </summary>
        public string Zeile { get; set; }

        /// <summary>
        /// 采购订单号
        /// </summary>
        public string PurOrderNo { get; set; }

        /// <summary>
        /// 采购订单行号(西安拣配单行号)
        /// </summary>
        public string PurOrderLineNo { get; set; }

        /// <summary>
        /// 采购订单行项目类型：0-无；1-L外协；2-U转储;3-正常采购
        /// </summary>
        public int? PurOrderLineType { get; set; }

        /// <summary>
        /// 生产订单号-西安生产厂家编号
        /// </summary>
        public string ProOrderNo { get; set; }

        /// <summary>
        /// 部门编码（西安WBS码）
        /// </summary>
        public string DeptCode { get; set; }

        /// <summary>
        /// 部门名称（西安目标仓位）
        /// </summary>
        public string DeptName { get; set; }

        /// <summary>
        /// 货主Id
        /// </summary>
        public int? OwnerId { get; set; }

        /// <summary>
        /// 货主
        /// </summary>
        public string OwnerName { get; set; }

        /// <summary>
        /// 发货单号(销售订单号)
        /// </summary>
        public string DisOrderNo { get; set; }

        /// <summary>
        /// 发货单行号(销售订单行号)
        /// </summary>
        public string DisOrderLineNo { get; set; }

        /// <summary>
        /// 出库凭证
        /// </summary>
        public int? RefOutVoucherId { get; set; }

        /// <summary>
        /// 派遣订单
        /// </summary>
        public int? RefDispatchOrderId { get; set; }

        /// <summary>
        /// 合同编号
        /// </summary>
        public string ContractNo { get; set; }

        /// <summary>
        /// 是否多托盘
        /// </summary>
        public bool? IsMultPallet { get; set; }

        /// <summary>
        /// 是否挂起
        /// </summary>
        public bool? IsSuspend { get; set; }

        /// <summary>
        /// 仓库Id
        /// </summary>
        public int? WarehouseId { get; set; }

        /// <summary>
        /// 是否出库核审
        /// </summary>
        public bool? IsOutOrderReview { get; set; }

        /// <summary>
        /// 是否一次出库
        /// </summary>
        public bool? IsOnceOut { get; set; }

        public Guid? OnceOutGroupGuid { get; set; }

        /// <summary>
        /// 生成厂家
        /// </summary>
        public string? ProduceFactory { get; set; }

        /// <summary>
        /// 供应商名称
        /// </summary>
        public string? SupplierName { get; set; }

        /// <summary>
        /// 供应商Id
        /// </summary>
        public int? SupplierId { get; set; }
        /// <summary>
        /// 客户id
        /// </summary>
        public int? CustomerId { get; set; }
        /// <summary>
        /// 客户名称
        /// </summary>
        public string? CustomerName { get; set; }
        /// <summary>
        /// 车牌号
        /// </summary>
        public string CarCord { get; set; }

        /// <summary>
        /// 托盘条码
        /// </summary>
        [NotMapped]
        public string PalletBarcode { get; set; }

        #region 弃用
        ///// <summary>
        ///// 进度
        ///// </summary>
        //[NotMapped]
        //public decimal? ProgressValue
        //{
        //    get
        //    {
        //        if (PickedQty <= 0 || Qty <= 0)
        //        {
        //            return 0;
        //        }

        //        if (Qty == 0 || Qty==null)
        //        {
        //            return 0;
        //        }

        //        return Math.Truncate(PickedQty.GetValueOrDefault() * 1000.0M / Qty.GetValueOrDefault()) / 10;
        //    }
        //}
        //[NotMapped]
        //public List<TInventory> InventoryList { get; set; }
        #endregion


        [NotMapped]
        public List<TShippingLockCell> LockCelllist { get; set; }

        #region 西安煤科院
        /// <summary>
        /// 拣配单唯一ID
        /// </summary>
        public string OrderId { get; set; }

        /// <summary>
        /// 订单单位
        /// </summary>
        public string BaseUnit { get; set; }

        /// <summary>
        /// 客户号
        /// </summary>
        public string CustomNo { get; set; }

        /// <summary>
        /// 供应商编码
        /// </summary>
        public string SupplierCode { get; set; }

        /// <summary>
        /// 基本单位入库数量
        /// </summary>
        [Column(TypeName = "decimal(18,2)")]
        public decimal? BaseQuantity { get; set; } = 0;
        #endregion
    }
}